<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2014/10/15
 * Time: 16:28
 * 网点对标
 */
class BenchmarkController extends FrontController
{
    /**
     * 对标操作
     */
    public function actionIndex()
    {
        $networkquestion = new NetworkQuestion();
        $question = new QuestionBase();
        $project = new Project();
        $network = new NetWork();
        //根据网点等级查询
        $level = $this->get('level', 0);
        //审核状态
        $search_audit = $this->get('audit',-1);
        $question_list = array();
        $project_list = array();
        //如果是最后一级网点,直接查出此网点的项目与问卷
        if ($this->auth_grade == 4) 
        {
            $data = $this->level4();
        } elseif($this->auth_grade == 1) {//如果是总行
            $data = $this->level1();
        } elseif ($this->auth_grade == 2) {//分行级别,只有支行下级,或者没有支行
            $data = $this->level2();   
        } elseif ($this->auth_grade == 3) {//只是支行级别,只获取此级别项目即可
            $data = $this->level3();
        }
        if (!$data) {
                $this->smarty->display('error.tpl');exit;
        }


        $project_question_id = $this->get('project_question_id');
        if ($project_question_id) {
                $arr = explode('-', $project_question_id);
                $project_id = $arr[0];
                $question_id = $arr[1];
        }
        
        $tips = array();
        if ($data['netquestion']) {
            foreach ($data['netquestion'] as $key => $val) {
                $network_id = $val['network_id'];
                $network_info = NetWork::model()->findByPk($network_id)->attributes;
                $data[$key]['network_name'] = $network_info['network_name'];
                if ($level && $network_info && ($level!=$network_info['level'])) {
                    unset($data['netquestion'][$key]);
                    continue;
                }
                if ($question_id && $val['question_id']!=$question_id) {
                    unset($data['netquestion'][$key]);
                    continue;
                }
                if ($search_audit!=-1 && $search_audit!= $val['audit']) {
                    unset($data['netquestion'][$key]);
                    continue;
                }
                //判断当前登录网点是否已经此次网点做过操作，如果做过就不做提示，如果没做过就要做提示
                if (!QuestionBenchmark::model()->count("nq_id={$val['nq_id']} and network_id={$this->network_id}"))
                {
                    $tips[$val['nq_id']] = $val['network_name'];
                }
            }
        }
        //print_r($data);exit;
        if ($data['netquestion'])
        {
            //$res = [];
            //print_r($data['netquestion']);
            foreach ($data['netquestion'] as $key => $val){
                $kk = $val['network_id'].'-'.$val['nq_id'];
                $res[$kk] = $val;
            }
            ksort($res);
            $data['netquestion'] = $res;
            //print_r($data[netquestion]);
        }
        //print_r($data['question_list']);
        $this->smarty->assign('tips', empty($tips) ? $tips : join("，", $tips));
        $this->smarty->assign('netquestion', $data['netquestion']);
        $this->smarty->assign('project_question', $data['project_question']);
        $this->smarty->assign('question_list', $data['question_list']);
        $this->smarty->assign('project_list', $data['project_list']);
        $this->smarty->assign('audit', NetworkQuestion::$audit);
        $this->smarty->assign('audit_show', NetworkQuestion::$audit_show);
        $this->smarty->assign('level_auth', NetworkQuestion::$level_auth[$this->auth_grade]);
        $this->smarty->assign('question_id', $question_id);
        $this->smarty->assign('network_id', $this->network_id);
        $this->smarty->assign('level_list', NetWork::networkLevel());
        $this->smarty->assign('current_level', $level);
        $this->smarty->assign('project_info', Project::model()->findByPk($project_id)->attributes);
        $this->smarty->assign('search_audit', $search_audit);
        $this->smarty->assign('network_id', $network_id);
        $this->smarty->assign('notshowscore', array(79,80,82,83,84,85,89,90,147,148,88,90,63,73,150,151,152));
        $this->smarty->display('benchmark/index.tpl');
    }
    /**
     * 如果是总行，显示所有扣分网点和选项
     */
    public function actionAll(){
        if ($this->auth_grade != 1) {
            echo '<script>alert("只有总行有查看权限");window.history.go("-1");</script>';
            exit;
        }
        $question_id = (int)$this->get('question_id');
        $nq_id = (int)$this->get('nq_id');
        $subject_id = (int)$this->get('subject_id');
        $next_network_id = (int)$this->get('next_network_id');
        $data = $this->level1();
         
        //指定问卷
        if (!$question_id) {
            $arr = array_keys($data['question_list']);
            $question_id = $arr[0];
        }
        //根据下级查找时
        $nq_ids = $nlist = array();
        //总行的下级银行
        $next_network = NetWork::model()->findAll('up_network_id='.$this->network_id);
        $this->smarty->assign('next_network', $next_network);
        //下级银行的网点
        if ($next_network_id) {
            $next_info = NetWork::model()->findByPk($next_network_id)->attributes;
            $nlist = NetWork::model()->getAllNext($next_info['network_id'], $next_info['auth_grade']);
            
            if ($nlist) {
                foreach ($nlist as $key => $val) {
                    $info = NetworkQuestion::model()->find("network_id={$val['network_id']} and question_id={$question_id}");
                    $nq_ids[] = $info['nq_id'];
                    $network[$info['nq_id']] = $val['network_name'];
                }
                //第四级网点
                $this->smarty->assign('nlist', $network);
            }
        }
        $this->smarty->assign('next_network_id', $next_network_id);

        $question = new QuestionBase();
        $question_info = $question->findByPk($question_id)->attributes;
        
        //问题的选项
        $questionoption = new QuestionOption();
        $option = $questionoption->getByQuestion($question_id);
        
        //问卷题目
        $questionsubject = new QuestionSubject();
        $criteria = new CDbCriteria();
        $criteria->addColumnCondition(array('question_id' => $question_id));
        $criteria->addColumnCondition(array('is_basic' => 0));
        $criteria->order = 'classify_id asc';
        //下拉列表
        $show_subject_list = $questionsubject->findAll($criteria);
        $this->smarty->assign('show_subject_list', $show_subject_list);
        
        if ($subject_id) {
            $criteria->addColumnCondition(array('subject_id' => $subject_id));
        }
        
        $subject_list = $questionsubject->findAll($criteria);
        //print_r($subject_list);exit;
        //找到每个问题的所有网点回答
        $network_subject_answer = array();
        $benchmark_list = array();
        foreach ($subject_list as $key => $val) {
            $answer = NetworkQuestionAnswer::model()->findAll('subject_id = '.$val['subject_id']);
            if ($answer) {
                foreach ($answer as $k => $v) {
                    //只显示扣分项，不是标准分或者有扣分人员的
                    if (is_numeric($val['standard_score']) && ($val['standard_score'] != $v['answer_score'])) {
                        if ($nq_id && $nq_id != $v['nq_id']) {
                            continue;
                        } elseif ($nq_ids && !in_array($v['nq_id'], $nq_ids)) {
                            continue;
                        }
                        $network_subject_answer[$val['subject_id']][$v['nq_id']] = $v;
                        $benchmark_list[$val['subject_id']][$v['nq_id']] = QuestionBenchmark::model()->count("nq_id={$v['nq_id']} and subject_id={$val['subject_id']} and is_self=1");
                    }
                }
            }
        }
        
        //print_r($data['netquestion_name']);exit;
        //print_r($network_subject_answer);exit;
        $this->smarty->assign('benchmark_list', $benchmark_list);
        $this->smarty->assign('netquestion_name', $data['netquestion_name']);
        $this->smarty->assign('network_subject_answer', $network_subject_answer);
        $this->smarty->assign('question_option', $option);
        $this->smarty->assign('question_info', $question_info);
        $this->smarty->assign('subject_list', $subject_list);
        $this->smarty->assign('question_id', $question_id);
        $this->smarty->assign('question_list', $data['question_list']);
        $this->smarty->assign('nq_id', $nq_id);
        $this->smarty->assign('subject_id', $subject_id);
        $this->smarty->assign('next_network_id',$next_network_id);
        $this->smarty->display('benchmark/all.tpl');
    }
    /**
     * 修改结点状态
     * 打回或者提交，记录历史记录
     */
    public function actionSetAudit(){
        $nq_id = $this->request('nq_id');
        $audit = $this->request('audit');
        if (empty($nq_id)) {
            $this->_ajax(array('status' => 0, 'note' => '请选择网点问卷'));
        }
        if (empty($audit)) {
            $this->_ajax(array('status' => 0, 'note' => '请选择结点状态'));
        }
        //向上提交
        if ($audit == 2) {
            $node_id  = $this->myuplevel(true);
        }
        //向下打回
        if ($audit == 3) {
            $node_id = $this->myuplevel(false);
        }
        //提交(总行)
        if ($audit == 4) 
        {
            $node_id = 1;
        }
        $netquestion = new NetworkQuestion();
        if ($netquestion->updateByPk($nq_id,array('audit' => $audit,'update_time' => time(),'node_id' => $node_id,'op_node_id'=>$this->level))){
            foreach ($nq_id as $id) {
                //记录历史记录
                $questionaudit = NetworkQuestionAudit::model()->find("nq_id=:id and network_id=:network_id", array(':id' => $id,':network_id' => $this->network_id));
                if (!$questionaudit) {
                    $questionaudit = new NetworkQuestionAudit();
                    $questionaudit->nq_id = $id;
                    $questionaudit->network_id = $this->network_id;
                    $questionaudit->level = $this->auth_grade;
                    $questionaudit->create_time = time();
                    $questionaudit->audit = $audit;
                    $questionaudit->save();
                } else {
                    $data['nq_id'] = $id;
                    $data['network_id'] = $this->network_id;
                    $data['level'] = $this->auth_grade;
                    $data['create_time'] = time();
                    $data['audit'] = $audit;
                    NetworkQuestionAudit::model()->updateByPk($questionaudit['nqu_id'],$data);
                }
                
            }

            $this->_ajax(array('status' => 1, 'note' => '提交成功'));
        } else {
            $this->_ajax(array('status' => 0, 'note' => '提交失败'));
        }
    }
    /**
     * 审核历史记录
     */
    public function actionAuditHistory()
    {
        $nq_id = (int)$this->get('nq_id');
        $criteria = new CDbCriteria();
        $criteria->addColumnCondition(array('nq_id' => $nq_id));
        $criteria->order = 'create_time desc';
        $list = NetworkQuestionAudit::model()->findAll($criteria);
        if ($list) {
            foreach ($list as $key => $val) {
                $network_id = $val['network_id'];
                $info = NetWork::model()->findByPk($network_id)->attributes;
                $list[$key]['network_name'] = $info['network_name'];
            } 
        }
        $this->smarty->assign('networklevel', NetWork::networkLevel());
        $this->smarty->assign('list', $list);
        $this->smarty->assign('audit', NetworkQuestion::$audit);
        $this->smarty->display('benchmark/audithistory.tpl');

    }
    /**
     * 修改问卷状态
     */
    public function actionSetStatus(){
        $status = (int)$this->get('status');
        $nq_id = (int)$this->get('nq_id');
        $networkquestion = new NetworkQuestion();
        $info = $networkquestion->findByPk($nq_id)->attributes;
        $question_id = intval($info['question_id']);

        if ($networkquestion->updateByPk($nq_id, array('status' => $status))) {
            //如果是完成状态，修改问卷完成数量
            if ($status == NetworkQuestion::NETWORK_QUESTION_COMPLETE) {
                $total = $networkquestion->count('question_id='.$question_id.' and status='.NetworkQuestion::NETWORK_QUESTION_COMPLETE);
                $question = new QuestionBase();
                $question->updateByPk($question_id, array('complete_question_num' => $total));
            }
            $this->_ajax(array('status' => 1, 'note' => '设置成功'));
        } else {
            $this->_ajax(array('status' => 0, 'note' => '设置失败'));
        }
    }
    /**
     * 预览
     */
    public function actionView(){
        $nq_id = (int)$this->get('nq_id');
        $subject_id = (int)$this->get('subject_id');//定位用
        //网点问卷信息
        $netquestion = new NetworkQuestion();
        $netquestion_info = $netquestion->findByPk($nq_id)->attributes;
        //网点信息
        $network = new NetWork();
        $network_info = $network->findByPk($netquestion_info['network_id'])->attributes;
        $this->smarty->assign('network_info', $network_info);
        //是否本网点自己预览
        if ($this->network_id == $netquestion_info['network_id']) {
            $this->smarty->assign('current_network_id', 1);
        } else {
            $this->smarty->assign('current_network_id', 0);
        }
        //上级网点信息
        if ($network_info) {
            $up_network_info = $network->findByPk($network_info['up_network_id']);
            $this->smarty->assign('up_network_info', $up_network_info);
        }
        
        //问卷基本信息
        $question_id = $netquestion_info['question_id'];
        $question = new QuestionBase();
        $question_info = $question->findByPk($question_id)->attributes;
        
        //问卷题目
        $questionsubject = new QuestionSubject();
        $subject_list = $questionsubject->getByGroupClassify($question_id);
        
        //问卷基本扩展基本信息，从题目里面出
        $basic_list = $questionsubject->getBasic($question_id);

        //问卷的区块
        $subjectclassify = new QuestionSubjectClassify();
        $classify_list = $subjectclassify->getByQuestion($question_id);
        //print_r($classify_list);exit;


        //问题的选项
        $questionoption = new QuestionOption();
        $option = $questionoption->getByQuestion($question_id);

        //问卷回答
        $answer = new NetworkQuestionAnswer();
        $answer_list = $answer->getByNq($nq_id);

        //print_r($answer_list);exit;
        //回答的附件
        $attach = new NetworkQuestionAttach();
        $attach_list = $attach->getByNq($nq_id);

        //题目是否有异议
        $benchmark = new QuestionBenchmark();
        $benchmark_list = $benchmark->getNqList($nq_id);
        //print_r($benchmark_list);
        
        //题目的赛诺审核意见
        $benchmarkManage = new QuestionBenchmarkManage();
        $manage_list = $benchmarkManage->getNqList($nq_id);
        	
        //当前网点是否对此问卷提交过，对过那离开时不需要判断
        $is_submit = NetworkQuestionAudit::model()->count("nq_id={$nq_id} and network_id={$this->network_id}");
        $this->smarty->assign('is_submit', $is_submit);

        $this->smarty->assign('benchmark_list', $benchmark_list);
        $this->smarty->assign('manage_list', $manage_list);
        $this->smarty->assign('netquestion_info', $netquestion_info);
        $this->smarty->assign('question_info', $question_info);
        $this->smarty->assign('subject_list', $subject_list);
        $this->smarty->assign('basic_list', $basic_list);
        $this->smarty->assign('classify_list', $classify_list);
        $this->smarty->assign('option_list', $option);
        $this->smarty->assign('answer_list', $answer_list);
        $this->smarty->assign('attach_list', $attach_list);
        $this->smarty->assign('nq_id', $nq_id);
        $this->smarty->assign('audit', NetworkQuestion::$audit);
        $this->smarty->assign('level_auth', NetworkQuestion::$level_auth[$this->auth_grade]);
        $this->smarty->assign('subject_id', $subject_id);
        $this->smarty->assign('notshowscore', array(79,80,82,83,84,85,89,90,147,148,88,90,63,73,150,151,152));
        $this->smarty->display('benchmark/view.tpl');

    }
    /**
     * 查看附件
     * 问卷回答的附件
     */
    public function actionAttach(){   
        $nq_id = (int)$this->get('nq_id');
        $subject_id = (int)$this->get('subject_id');
        //网点信息
        $netquestion = new NetworkQuestion();
        $net_info = $netquestion->findByPk($nq_id)->attributes;
        $this->smarty->assign('net_info', $net_info);
        //问卷名称
        $question = new QuestionBase();
        $question_info = $question->findByPk($net_info['question_id'])->attributes;
        $this->smarty->assign('question_info', $question_info);
        //题目信息
        $subject = new QuestionSubject();
        $subject_info = $subject->findByPk($subject_id)->attributes;

        $this->smarty->assign('subject_info', $subject_info);
        $attach = new NetworkQuestionAttach();
        $list = $attach->getBySubject($nq_id, $subject_id, true);
        //print_r($list);
        //对标信息
        $answer = NetworkQuestionAnswer::model()->getBySubject($nq_id, $subject_id);

        //拆分一下，找图片对应关系，一对多实现不了
        if (stripos($answer['answer_desc'],';')!==false) {
            $answer_desc_list = explode(';', $answer['answer_desc']);
        } else {
            $answer_desc_list = explode('；', $answer['answer_desc']);
        }
        
        $this->smarty->assign('answer_desc_list', $answer_desc_list);
        $this->smarty->assign('answer', $answer);
        $this->smarty->assign('list', $list);
        $this->smarty->display('benchmark/attach.tpl');
    }
    /**
     * 每个问题网点对标的附件
     * 对标的附件
     * 其实就是网点申请还分的附件，
     * 现已改成只下载，不预览
     * 此部分不再使用
     */
    public function actionDuibiaoAttach()
    {
        $nq_id = intval($this->get('nq_id'));
        $subject_id = intval($this->get('subject_id'));
        $network_id = intval($this->get('network_id'));
        $attach = new QuestionBenchmarkAttach();
        $result = $attach->getBySubject($nq_id, $subject_id, $network_id ? $network_id : $this->network_id);
        $this->smarty->assign('list', $result);
        $this->smarty->display('benchmark/duibiao_attach.tpl');
    }
    /**
     * 删除benchmark_attach里的附件
     * 同时计算下这次对标申请是否还有附件
     */
    public function actionDelBenchAttach()
    {
        $qba_id = $this->get('qba_id');
        $info = QuestionBenchmarkAttach::model()->findByPk($qba_id);
        $info->status = 0;
        if ($info->save()) {
            if (QuestionBenchmarkAttach::model()->count('nq_id='.$info->nq_id.' and subject_id='.$info->subject_id.' and network_id='.$info->network_id.' and status=1')==0) {
                QuestionBenchmark::model()->updateAll(array('haveattach'=>0),'nq_id='.$info->nq_id.' and subject_id='.$info->subject_id.' and network_id='.$info->network_id);
            }
            $this->_ajax(array('status' => 1,'note' => '删除成功'));
        } else {
            $this->_ajax(array('status' => 0,'note' => '删除失败'));
        }
    }
    /**
     * 对标操作页面
     * 对标还分申请只能本网点自己申请
     * 其他上级网点都是提出意见
     */
    public function actionDuibiao(){
        $nq_id = (int)$this->get('nq_id');
        $subject_id = (int)$this->get('subject_id');

        $info = QuestionBenchmark::model()->find('nq_id='.$nq_id.' and subject_id='.$subject_id.' and network_id='.$this->network_id);
        if ($info) {//如果已经做过
            $this->smarty->assign('info', $info);
            $this->smarty->assign('nq_id', $info['nq_id']);
            $this->smarty->assign('subject_id', $info['subject_id']);
            $subject_id = $info['subject_id'];
            //如果是修改查出来已有的附件
            $attachlist = QuestionBenchmarkAttach::model()->getBySubject($nq_id, $subject_id, $this->network_id);
            $this->smarty->assign('attachlist', $attachlist);
        } else {
            $this->smarty->assign('nq_id', $nq_id);
            $this->smarty->assign('subject_id', $subject_id);
        }
        //题目信息
        $subject = QuestionSubject::model()->findByPk($subject_id)->attributes;
        //项目信息
        $netinfo = NetworkQuestion::model()->findByPk($nq_id)->attributes;
        $project = Project::model()->findByPk($netinfo['project_id'])->attributes;
        $this->smarty->assign('project', $project);
        $this->smarty->assign('subject_info', $subject);
        $this->smarty->assign('network_id', $this->network_id);
        $this->smarty->assign('referer',Yii::app()->request->hostInfo.'/benchmark/view?nq_id='.$nq_id);
        $this->smarty->assign('iframe', $this->get('iframe'));
        $this->smarty->display('benchmark/duibiao_new.tpl');
    }
    /**
     * 替代doaudit
     * 网点申请还分操作
     */
    public function actionDoDuibiao()
    {
        $qb_id = (int)$this->post('qb_id');
        $subject_id = (int)$this->post('subject_id');
        $nq_id = (int)$this->post('nq_id');
        if ($qb_id) {
            $qbenchmark = QuestionBenchmark::model()->findByPk($qb_id);  
        } else {
            $qbenchmark = new QuestionBenchmark();
        }
       //得到问卷信息
        $info = NetworkQuestion::model()->findByPk($nq_id)->attributes;
        $qbenchmark->nq_id = $nq_id;
        $qbenchmark->subject_id = $subject_id;
        $qbenchmark->suggestion = $this->post('suggestion');
        $qbenchmark->isreturn = 1;//默认申请还分
        $qbenchmark->network_id = $this->network_id;
        $qbenchmark->level = $this->level;
        $qbenchmark->update_time = date('Y-m-d H:i:s');
        if ($this->network_id == $info['network_id']) {
            $qbenchmark->is_self = 1;
        }
        //判断是否有附件
        if (QuestionBenchmarkAttach::model()->count('nq_id='.intval($nq_id).' and subject_id='.intval($subject_id).' and status=1')){
            $qbenchmark->haveattach = 1;
        }
        if ($qbenchmark->save()){
            $this->_ajax(array('status' => 1,'note' => '成功'));
        } else {
            $this->_ajax(array('status' => 0,'note' => '失败'));
        }
    }
    /**
     * 对标历史
     */
    public function actionHistory(){
        $nq_id = (int)$this->get('nq_id');
        $subject_id = (int)$this->get('subject_id');
        $benchmark = new QuestionBenchmark();
        $list = $benchmark->getBySubject($nq_id, $subject_id);
        //网点问卷信息
        $netquestion = NetworkQuestion::model()->findByPk($nq_id)->attributes;
        $this->smarty->assign('netquestion', $netquestion);
        //问卷信息
        $question = QuestionBase::model()->findByPk($netquestion['question_id'])->attributes;
        $this->smarty->assign('question', $question);
        //后台网点对前台审核的回复
        $benchmarkmanage = new QuestionBenchmarkManage();
        $managelist = $benchmarkmanage->getBySubject($nq_id, $subject_id);
        $this->smarty->assign('network_id', $this->network_id);
        $this->smarty->assign('list', $list);
        $this->smarty->assign('managelist', $managelist);
        $this->smarty->assign('networklevel', NetWork::networkLevel());
        $this->smarty->display('benchmark/history.tpl');
    }
    /**
     * 删除对标
     * 删除申请记录
     * 同时删除附件
     */
    public function actionDelAudit()
    {
        $qb_id = intval($this->get('qb_id'));
        $benchmark = new QuestionBenchmark();
        $info = $benchmark->findByPk($qb_id)->attributes;
        if ($benchmark->deleteByPk($qb_id)) {
            //同时删除附件
            QuestionBenchmarkAttach::model()->deleteAll("nq_id={$info['nq_id']} and subject_id={$info['subject_id']}");
            $this->_ajax(array('status' => 1, 'note' => '删除成功'));
        } else {
            $this->_ajax(array('status' => 0, 'note' => '删除失败'));
        }
    }
    /**
     * 上级网点针对用户的申请还分的申请给出意见或建议，并打回或者提交
     * 审核意见
     */
    public function actionSuggest()
    {
        $nq_id = $this->get('nq_id');
        $subject_id = $this->get('subject_id');
        //是否提交过
        $qbenchmark = new QuestionBenchmark();
        $info = $qbenchmark->find('nq_id='.$nq_id.' and subject_id='.$subject_id.' and network_id='.$this->network_id);
        $this->smarty->assign('info', $info);
        //题目信息
        $subject = QuestionSubject::model()->findByPk($subject_id)->attributes;
        $this->smarty->assign('subject_info', $subject);
        $this->smarty->assign('network_id', $this->network_id);
        $this->smarty->assign('nq_id', $nq_id);
        $this->smarty->assign('subject_id', $subject_id);
        $this->smarty->assign('referer',Yii::app()->request->hostInfo.'/benchmark/view?nq_id='.$nq_id);
        $this->smarty->assign('iframe', $this->get('iframe'));
        $this->smarty->display('benchmark/suggest.tpl');
    }
    /**
     * 上级填写意见
     */
    public function actionDosuggest()
    {
        $subject_id = (int)$this->post('subject_id');
        $nq_id = (int)$this->post('nq_id');
        $qb_id = (int)$this->post('qb_id');
        $qbenchmark = new QuestionBenchmark();
        //如果不是修改先判断此操作网点是否对此题有过操作，有过操作的话提示修改
        if (!$qb_id && $qbenchmark->count('nq_id='.$nq_id.' and subject_id='.$subject_id.' and network_id='.$this->network_id)) {
            $this->_ajax(array('status' => 0,'note' => '您已经操作过，请到历史操作里面查看'));
        }
        if ($qb_id) {
            $qbenchmark = QuestionBenchmark::model()->findByPk($qb_id);
        }
       
        $qbenchmark->nq_id = $nq_id;
        $qbenchmark->subject_id = $subject_id;
        $qbenchmark->suggestion = $this->post('suggestion');
        $qbenchmark->network_id = $this->network_id;
        $qbenchmark->level = $this->level;
        $qbenchmark->update_time = date('Y-m-d H:i:s');
        if ($this->level  == 1) {//如果是总行
            $qbenchmark->last_time = date('Y-m-d');
        }
        if ($qbenchmark->save()){
            $this->_ajax(array('status' => 1,'note' => '成功'));
        } else {
            $this->_ajax(array('status' => 0,'note' => '失败'));
        }
    }
    /**
     * 附件下载
     */
    public function actionDown()
    {
        $nq_id = $this->get('nq_id');
        $subject_id = $this->get('subject_id');
    }
}